function element_add(url, cate)
{
	var val = document.getElementById("in_" + cate).value;
	//window.location.href = url + "?cate=" + cate + "&val=" + val;

	var req = new XMLHttpRequest();

	if (cate == null)
		return;

	req.onreadystatechange= function ()
  	{
  		if (req.readyState == 4 && req.status == 200)
    		{
			document.getElementById("main").innerHTML = req.responseText;
		}
	}

	req.open("GET", url + "?cate=" + cate + "&val=" + val, true);
	req.send();

}

function element_remove(url, cate, sub)
{
	if (confirm("You are about to delete this element. \nThis won't delete elements depending on it, but it will not show here anymore. \nClick Ok to confirm the deletion.\nClick Cancel to keep the element."))
	{
		var req = new XMLHttpRequest();

		if (cate == null)
			return;

		req.onreadystatechange= function ()
		{
			if (req.readyState == 4 && req.status == 200)
			{
				document.getElementById("main").innerHTML = req.responseText;
			}
		}
	
		req.open("GET", url + "?cate=" + cate + "&sub=" + sub, true);
		req.send();
		
	}
}

function fill_frame(key, url, ent)
{
	if (key != "Resources" && key != "Factions" && key != "Statistics")
		document.getElementById("rightManagement").src = url + "?entity=" + ent;
}

function entity_asynch_load(url, ent)
{
	var req = new XMLHttpRequest();

	if (ent == null)
		return;

	req.onreadystatechange= function ()
  	{
  		if (req.readyState == 4 && req.status == 200)
    		{
			document.getElementById("entityCard").innerHTML = req.responseText;
		}
	}

	req.open("GET", url + "?entity=" + ent, true);
	req.send();
}
